﻿using System.Diagnostics;
using BlogsAPI.Interfaces;

namespace BlogAPIUnitTest
{
    using System;
    using BlogsAPI.Abstract;
    using BlogsAPI.Shorteners;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class Shorteners
    {
        private void RunTest(Shortener oServer)
        {
            String sRet = oServer.ConvertDataTo("http://blogs.mail.ru/mail/topbloger/#0CDFAE218ECB5411", ItemType.FullUrl, ItemType.ShortUrl);
            Assert.AreEqual(false,String.IsNullOrEmpty(sRet));
            Debug.WriteLine("Returns: " + sRet);
            sRet = oServer.ConvertDataTo(sRet, ItemType.ShortUrl, ItemType.FullUrl);
            Assert.IsTrue(String.IsNullOrEmpty(sRet));
            Debug.WriteLine("BackTrace: " + sRet);
        }

        [TestMethod]
        public void Bitly()
        {
            RunTest(new BitLy());
        }

        [TestMethod]
        public void Cligs()
        {
            RunTest(new Cligs());
        }


        [TestMethod]
        public void Isgd()
        {
            RunTest(new Isgd());
        }

        [TestMethod]
        public void Clck()
        {
            RunTest(new Clck());
        }

        [TestMethod]
        public void B23()
        {
            B23 b = new B23();
            RunTest(b);
            Debug.WriteLine("Clicks: " + b.ConvertDataTo("ehfl", ItemType.HashTag, ItemType.Clicks));
        }

        [TestMethod]
        public void Googl()
        {
            RunTest(new Googl());
        }

        [TestMethod]
        public void TcoTest()
        {
            Tco oTco = new Tco();
            //string sRet = "http://t.co/QvHjs7Ag";
            string sRet = "http://t.co/8jUA8RMb";
            sRet = oTco.ConvertDataTo(sRet, ItemType.ShortUrl, ItemType.FullUrl);
            Assert.IsTrue(String.IsNullOrEmpty(sRet));
            Debug.WriteLine("BackTrace: " + sRet);
        }

        [TestMethod]
        public void vkcc()
        {
            Vkcc vk = new Vkcc();
            string sRet = "http://vk.cc/YIx3Z";
            sRet = vk.ConvertDataTo(sRet, ItemType.ShortUrl, ItemType.FullUrl);
            Assert.IsTrue(String.IsNullOrEmpty(sRet));
            Debug.WriteLine("BackTrace: " + sRet);
        }

        [TestMethod]
        public void YoutubeTest()
        {
            var oYoutube = new Youtube();
            string sRet = "http://youtu.be/BjEG5B5hDAY";
            sRet = oYoutube.ConvertDataTo(sRet, ItemType.ShortUrl, ItemType.FullUrl);
            Assert.IsTrue(String.IsNullOrEmpty(sRet));
            Debug.WriteLine("BackTrace: " + sRet);
        }
        
        [TestMethod]
        public void TmblrTest()
        {
            var Tmblr = new Tmblrco();
            string sRet = "http://tmblr.co/ZDe3xm1MSG4ki";
            sRet = Tmblr.ConvertDataTo(sRet, ItemType.ShortUrl, ItemType.FullUrl);
            Assert.IsTrue(String.IsNullOrEmpty(sRet));
            Debug.WriteLine("BackTrace: " + sRet);
        }

        [TestMethod]
        public void FeedburnerText()
        {
            Feedburner oFB = new Feedburner();
            string sRet = "http://feeds.feedburner.com/~r/sport-express/ysFm/~3/URdU2M2MiSk/?utm_source=feedburner&utm_medium=twitter&utm_campaign=petrovik1984";
            sRet = oFB.ConvertDataTo(sRet, ItemType.ShortUrl, ItemType.FullUrl);
            Assert.IsTrue(String.IsNullOrEmpty(sRet));
            Debug.WriteLine("BackTrace: " + sRet);
        }
    }
}
